package easynotes.swingui.dyncom;

import easynotes.concerns.Links;
import easynotes.concerns.NotesPresentation;
import easynotes.concerns.TODO;
import easynotes.concerns.UI;
import easynotes.swingui.EasyNotesFrame;
import javax.swing.JComponent;

/**
 *
 * @author Milan
 */
@Links
@NotesPresentation(task = NotesPresentation.Task.LINKS)
@UI
@TODO("Finish opening files in pdf reader")
public class ShowLinksPanel extends javax.swing.JPanel implements LinksPanel {

    /**
     * Creates new form ShowLinksPanel
     */
    public ShowLinksPanel() {
        initComponents();
    }

    @Override
    public void setLink(String link) {
        this.link.setText(link);
    }

    @Override
    public String getLink() {
        return this.link.getText();
    }
    
    @Override
    public JComponent asJComponent() {
        return this;
    }
    
    @UI
    public static class ShowLinksPanelFactory implements PanelsFactory<ShowLinksPanel> {

        @Override
        public ShowLinksPanel getNewInstance() {
            return new ShowLinksPanel();
        }
        
        public static ShowLinksPanelFactory getFactory() {
            return new ShowLinksPanel.ShowLinksPanelFactory();
        }
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        link = new javax.swing.JTextField();
        openButton = new javax.swing.JButton();

        setBackground(EasyNotesFrame.bckgColour);
        setBorder(javax.swing.BorderFactory.createLineBorder(EasyNotesFrame.bckgColour));

        link.setEditable(false);
        link.setBorder(null);
        link.setMaximumSize(new java.awt.Dimension(2147483647, 14));

        openButton.setBackground(EasyNotesFrame.bckg2Colour);
        openButton.setForeground(EasyNotesFrame.frg2Colour);
        openButton.setText("Open");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(link, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(openButton))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(link, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(openButton))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField link;
    private javax.swing.JButton openButton;
    // End of variables declaration//GEN-END:variables
}
